var fi = 1;
var page = 1;
var main = [[ //表头
		{
			title: '操作',
			minWidth: 120,
			toolbar: '#operation',
			fixed: 'left'
		},{
			field: 'name',
			title: '司机',
			sort: true,
			fixed: 'left',
			minWidth: 100
		}, {
			field: 'phone',
			title: '司机电话',
			sort: true
		}, {
			field: 'end_time',
			title: '上次订单结算时间'
		}, {
			field: 'task_time',
			width: 300,
			title: '预约时间'
		}, {
			field: 'number',
			width: 200,
			title: '绑定车辆',
			sort: true
		}, {
			field: 'work_state2',
			title: '状态'
		}
	]];
var data = {};
data.page = page;
data.pagenum = 10;
var where_json = {};
Load()
ajaxdriver(data)
function ajaxdriver(data) {
	ajax(api.driver.list, data, 'post').done((res) => {
		Load(1)
		console.log(res)
		if(res.code == 1) {
			table.render({
				elem: '#driver',
				cellMinWidth: 80,
				cols: main,
				data: res.data,
				limit: 10,
				even: true
			});
			if(fi == 1) {
				laypage.render({
					elem: 'page',
					count: 0,
					layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip'],
					theme: '#1E9FFF',
					jump: function(obj, first) {
						if(!first) {
							page = obj.curr
							data.page = page
							pagenum = obj.limit
							data.pagenum = pagenum
							ajaxdriver(data)
						} else {

						}
					}
				});
				fi = 2
			}
			table.on('tool(driver)', function (obj) {
    				var data1 = obj.data; //获得当前行数据
    				var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
    				var tr = obj.tr; //获得当前行 tr 的DOM对象
    				if(layEvent === 'choose') {
						var index = parent.layer.getFrameIndex(window.name);
						parent.$('.driver_id').val(data1.driver_id);
						parent.$('.driver_name').val(data1.name);
						parent.$('.car_id').val(data1.car_id);
						parent.layer.close(index);
					}
    		})
		} else {
			Err(res.msg)
		}
	}).fail(() => {
		Load();
		Err('请求失败')
	})
}